package com.only4play.portal.cp.bean.outbuilder.outxmlbuilder;

import com.only4play.portal.cp.bean.message.xmlmessage.CpXmlOutMessage;
import com.only4play.portal.cp.bean.outbuilder.AbstractBuilder;

/**
 * @author liyuncong
 * @version 1.0
 * @file BaseBuilder
 * @brief BaseBuilder
 * @details BaseBuilder
 * @date 2024-06-07
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-06-07               liyuncong          Created
 */
public abstract class XmlBaseBuilder<BuilderType, ValueType> extends AbstractBuilder<BuilderType, ValueType> {

    protected String fromUserName;

    protected String toUserName;

    public BuilderType toUser(String toUserName) {
        this.toUserName = toUserName;
        return (BuilderType) this;
    }

    public BuilderType fromUser(String fromUserName) {
        this.fromUserName = fromUserName;
        return (BuilderType) this;
    }

    public abstract ValueType build();

    public void setCommon(CpXmlOutMessage m) {
        m.setToUserName(this.toUserName);
        m.setFromUserName(this.fromUserName);
        m.setCreatedAt(System.currentTimeMillis() / 1000L);
    }
}
